﻿using System;
using System.Collections.Generic;
using System.Text;
using MyTask.Domain.Commands;
using MyTask.Domain.Commands.Handlers;
using MyTask.Domain.Models;
using MyTask.Domain.Queries;
using MyTask.Domain.Queries.Handlers;

namespace MyTask.Application.Services
{
    public class TaskInfoService : ITaskInfoService
    {
        #region Private variable
        private TaskInfoCommandHandler _taskInfoCommandHandler;
        private ShareTaskCommandHandler _shareTaskCommandHandler;
        private TaskInfoQueryHandler _taskInfoQueryHandler;
        #endregion
        #region Constructor
        public TaskInfoService(TaskInfoCommandHandler taskInfoCommandHandler,
                                             ShareTaskCommandHandler shareTaskCommandHandler,
                                              TaskInfoQueryHandler taskInfoQueryHandler)
        {
            _taskInfoCommandHandler = taskInfoCommandHandler;
            _shareTaskCommandHandler = shareTaskCommandHandler;
            _taskInfoQueryHandler = taskInfoQueryHandler;
        }
        #endregion
        #region Public method
        /// <summary>
        /// add task
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public bool AddTaskInfo(TaskInfoCommand command)
        {
            return _taskInfoCommandHandler.AddTaskInfo(command);
        }


        /// <summary>
        /// sharing task
        /// </summary>
        /// <param name="commands"></param>
        /// <returns></returns>
        public bool SharedTasks(List<ShareTaskCommand> commands)
        {
            return _shareTaskCommandHandler.SharedTasks(commands);
        }
        /// <summary>
        /// update user
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public bool UpdateTaskInfo(TaskInfoCommand command)
        {
            return _taskInfoCommandHandler.UpdateTaskInfo(command);
        }

        /// <summary>
        /// Get task ny taskid
        /// </summary>
        /// <param name="_query"></param>
        /// <returns></returns>
        public TaskInfo GetTaskInfoById(GetTaskInfoByIdQuery _query)
        {
            return _taskInfoQueryHandler.GetTaskInfoById(_query);
        }
        /// <summary>
        /// Get tasks by user
        /// </summary>
        /// <param name="_query"></param>
        /// <returns></returns>
        public List<TaskInfo> GetTaskInfosByUser(GetTaskInfosByUserQuery _query)
        {
            return _taskInfoQueryHandler.GetTaskInfosByUser(_query);
        }
        /// <summary>
        /// Get shared tasks by user
        /// </summary>
        /// <param name="_query"></param>
        /// <returns></returns>
        public List<TaskInfo> GetSharedTasksByUser(GetSharedTasksByUserQuery _query)
        {
            return _taskInfoQueryHandler.GetSharedTasksByUser(_query);
        }
        #endregion
    }
}
